package com.DreamTeam.daoProxy;

import java.util.List;

import com.DreamTeam.dao.ICustomerDao;
import com.DreamTeam.daoImpl.CustomerDao;
import com.DreamTeam.dbc.MySqlConnection;
import com.DreamTeam.po.Customer;
import com.DreamTeam.po.Employee;

public class CustomerDaoProxy implements ICustomerDao {
	private MySqlConnection conn;
	private ICustomerDao customerDao;

	public CustomerDaoProxy() {
		conn = new MySqlConnection();
		customerDao = new CustomerDao(conn.getConnection());
	}

	@Override
	public boolean doAdd(Customer customer) {
		// TODO Auto-generated method stub
		boolean flag = false;
		flag = customerDao.doAdd(customer);
		conn.closeConnection();
		return flag;
	}

	@Override
	public boolean doUpdate(Customer customer) {
		// TODO Auto-generated method stub
		boolean flag = false;
		flag = customerDao.doUpdate(customer);
		conn.closeConnection();
		return flag;
	}

	@Override
	public boolean doDelete(Customer customer) {
		// TODO Auto-generated method stub
		boolean flag = false;
		flag = customerDao.doDelete(customer);
		conn.closeConnection();
		return flag;
	}

	@Override
	public List<Customer> queryCustomerAll() {
		// TODO Auto-generated method stub
		List<Customer> list;
		list = customerDao.queryCustomerAll();
		conn.closeConnection();
		return list;
	}

	@Override
	public List<Customer> queryCustomerByColumn(String customerName,
			String columnName, String orderColumn, String model) {
		// TODO Auto-generated method stub
		List<Customer> list;
		list = customerDao.queryCustomerByColumn(customerName, columnName,
				orderColumn, model);
		conn.closeConnection();
		return list;
	}

	@Override
	public List<Customer> queryOrderByColumnName(String columnName, String model) {
		List<Customer> list;
		list = customerDao.queryOrderByColumnName(columnName, model);
		conn.closeConnection();
		return list;
	}

	@Override
	public List<Customer> queryByKeyword(String keyword) {
		List<Customer> list;
		list = customerDao.queryByKeyword(keyword);
		conn.closeConnection();
		return list;
	}
	

}
